package com.ssm.basis.configuration;

import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.ComponentScan.Filter;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import static com.ssm.basis.configuration.ConfigurationPackage.ROOT_PACKAGE;
import static org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication.Type.SERVLET;
import static org.springframework.context.annotation.FilterType.ANNOTATION;

/**
 * 只扫描 web 组件
 */
@ComponentScan(basePackages = ROOT_PACKAGE, includeFilters = {
        @Filter(type = ANNOTATION, classes = {Controller.class, ControllerAdvice.class})
}, useDefaultFilters = false)
@Configuration(proxyBeanMethods = false)
@ConditionalOnWebApplication(type = SERVLET)
class WebMvcConfiguration implements WebMvcConfigurer {
}
